#include "stdafx.h"
#include <wx/wxprec.h>

#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

#include "DebugEvent.h"

LUA_DEBUG_BEGIN

DEFINE_EVENT_TYPE(wxEVT_DEBUG_END_DEBUG);
DEFINE_EVENT_TYPE(wxEVT_DEBUG_CHANGED_STATE);
DEFINE_EVENT_TYPE(wxEVT_DEBUG_UPDATE_SOURCE);
DEFINE_EVENT_TYPE(wxEVT_DEBUG_ADDED_SOURCE);
DEFINE_EVENT_TYPE(wxEVT_DEBUG_CHANGED_BREAKPOINTS);
DEFINE_EVENT_TYPE(wxEVT_DEBUG_OUTPUT_LOG);
DEFINE_EVENT_TYPE(wxEVT_DEBUG_OUTPUT_INTERACTIVEVIEW);
DEFINE_EVENT_TYPE(wxEVT_DEBUG_FOCUS_ERRORLINE);
DEFINE_EVENT_TYPE(wxEVT_DEBUG_FOCUS_BACKTRACELINE);

wxDebugEvent::wxDebugEvent(wxEventType type, int winid) : wxEvent(winid, type)
{
    wxASSERT(
        type == wxEVT_DEBUG_END_DEBUG ||
        type == wxEVT_DEBUG_CHANGED_BREAKPOINTS);
}

wxDebugEvent::wxDebugEvent(wxEventType type, int winid, bool isBreak) : wxEvent(winid, type), m_isBreak(isBreak)
{
    wxASSERT(type == wxEVT_DEBUG_CHANGED_STATE);
}

wxDebugEvent::wxDebugEvent(wxEventType type, int winid, const std::string &key, int line, int updateCount, bool isRefreshOnly) : wxEvent(winid, type)
, m_key(key)
, m_line(line)
, m_updateCount(updateCount)
, m_isRefreshOnly(isRefreshOnly)
{
    wxASSERT(type == wxEVT_DEBUG_UPDATE_SOURCE);
}

wxDebugEvent::wxDebugEvent(wxEventType type, int winid, const std::string &key, int line) : wxEvent(winid, type), m_key(key), m_line(line)
{
    wxASSERT(type == wxEVT_DEBUG_FOCUS_ERRORLINE);
}

wxDebugEvent::wxDebugEvent(wxEventType type, int winid, const LuaBacktrace &bt) : wxEvent(winid, type), m_backtrace(bt)
, m_key(bt.GetKey()), m_line(bt.GetLine())
{
    wxASSERT(type == wxEVT_DEBUG_FOCUS_BACKTRACELINE);
}

wxDebugEvent::wxDebugEvent(wxEventType type, int winid, const Source &source) : wxEvent(winid, type), m_source(source)
{
    wxASSERT(type == wxEVT_DEBUG_ADDED_SOURCE);
}

wxDebugEvent::wxDebugEvent(wxEventType type, int winid, const LogData &logData) : wxEvent(winid, type)
, m_key(logData.GetKey())
, m_line(logData.GetLine())
, m_logData(logData)
{
    wxASSERT(type == wxEVT_DEBUG_OUTPUT_LOG);
}

wxDebugEvent::~wxDebugEvent()
{

}

wxEvent * wxDebugEvent::Clone() const
{
    return new wxDebugEvent(*this);
}

const Source & wxDebugEvent::GetSource() const
{
    return m_source;
}

const LuaBacktrace & wxDebugEvent::GetBacktrace() const
{
    return m_backtrace;
}

const std::string & wxDebugEvent::GetKey() const
{
    return m_key;
}

int wxDebugEvent::GetLine() const
{
    return m_line;
}

const LogData & wxDebugEvent::GetLogData() const
{
    return m_logData;
}

int wxDebugEvent::GetUpdateCount() const
{
    return m_updateCount;
}

bool wxDebugEvent::IsRefreshOnly() const
{
    return m_isRefreshOnly;
}

bool wxDebugEvent::IsBreak() const
{
    return m_isBreak;
}

LUA_DEBUG_END
